package org.dingyom.car.service.impl;

import org.dingyom.car.domain.CarResources;
import org.dingyom.car.mapper.CarResourcesMapper;
import org.dingyom.car.service.ICarResourcesService;
import org.dingyom.basics.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dingyom
 * @since 2022-09-08
 */
@Service
public class CarResourcesServiceImpl extends BaseServiceImpl<CarResources> implements ICarResourcesService {

    @Autowired
    private CarResourcesMapper carResourcesMapper;
    @Override
    public void addOrUpdate(CarResources carResources) {

        Long carId = carResources.getCarId();
        //无论是否有都删除原来
        carResourcesMapper.removeByCardId(carId);

        //再添加新的
        carResourcesMapper.save(carResources);
    }

    @Override
    public CarResources getByCarId(Long carId) {
        return carResourcesMapper.loadByCarId(carId);
    }
}
